package com.lowang.guava.test;

import java.util.concurrent.TimeUnit;
import com.google.common.util.concurrent.RateLimiter;

/**
 * @author Lo&Wang
 */
public class RateLimiterTest2 {
    public static void main(String[] args) throws InterruptedException {
        RateLimiter limiter = RateLimiter.create(5, 1000, TimeUnit.MILLISECONDS);
        for (int i = 1; i < 10; i++) {
            System.out.println(limiter.acquire(2));
        }
        Thread.sleep(2000L);
        for (int i = 1; i < 10; i++) {
            System.out.println(limiter.acquire());
        }
    }

}
